let form = document.querySelector('.layui-form')
let user_id = document.querySelector('.id')
let username = document.querySelector('.username')
let nickname = document.querySelector('.nickname')
let emil = document.querySelector('.email')


//let formaData=null

//console.log(formadata.get('username'));
axios({
  method: 'GET',
  url: `/my/userinfo`,


}).then(res => {
   console.log(res);
  let data = res.data.data
  user_id.value = data.id
  username.value = data.username
  nickname.value = data.nickname
  emil.value = data.email
  
  // console.log(formaData.get('id'));


})

form.addEventListener('submit', (e)=>{
  e.preventDefault()
  let formaData = new FormData(form)

  axios({
    method: 'post',
    url: '/my/userinfo',
    data: {
      id: formaData.get('id'),
      nickname: formaData.get('nickname'),
      email: formaData.get('email'),
      username:'2222'

    }
  }).then(res => {
    console.log(res);
    if(res.data.status===0){
      alert('修改成功')
    }
  })
})

